import { reactive } from 'vue'
import light from './light'
import dark from './dark'

const I18n = reactive({
    lang: 'light',
    package: {
        'light': light,
        'dark': dark
    } as any,
    setPkg: (_pkg: any) => {
        I18n.package = _pkg
    },
    setLang: (val: any) => {
        I18n.lang = val
    },
    get: (key: string): any => {
        const _sp = key.split('.')
        const _pkg = I18n.package[I18n.lang]
        let _res = _pkg[_sp[0]]
        for (let i = 1; i < _sp.length; i++) {
            _res = _res[_sp[i]]
        }
        return _res
    }
})

export default I18n
